﻿using B.S.DataBase.MyProject.Domain.Vendors;
using B.S.DataBase.MyProject.ErrorCode;
using B.S.DataBase.MyProject.Infrastructure.Interface;
using MediatR;
using T.E.ERP.Read.API.Applicantions.Command.VendorsCommand;

namespace T.E.ERP.Read.API.Applicantions.CommandHandler.VendorsCommandHandler
{
    /// <summary>
    /// 供应商分类表
    /// </summary>
    public class ProvendorCommandHandler : IRequestHandler<ProvendorCommand, APIResult<List<Supplierprovendor>>>
    {

        /// <summary>
        /// 原料供品表
        /// </summary>
        private readonly IBaseRepository<Supplierprovendor> rovenderRepository;

        public ProvendorCommandHandler(IBaseRepository<Supplierprovendor> rovenderRepository)
        {
            this.rovenderRepository = rovenderRepository;
        }

        public Task<APIResult<List<Supplierprovendor>>> Handle(ProvendorCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<Supplierprovendor>> result = new APIResult<List<Supplierprovendor>>();
            result.Code = APIEnum.查询成功;
            result.Msg = APIEnum.查询成功.ToString();

            var list = rovenderRepository.GetAll().Result;

            result.data = list.ToList();


            return Task.FromResult(result);
        }


    }
}
